package com.xyh.transaction.expression;

import com.xyh.transaction.entity.LoginUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * 自定义权限校验类
 *
 * @author xiao
 * @date 2023/11/19
 */
@Component("ex")
public class MyExpressionRoot {

//    public boolean hasAuthority(String authority) {
//        // 获取当前账号权限
//        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//        LoginUser loginUser = (LoginUser) authentication.getPrincipal();
//        List<String> permissions = loginUser.getPermissions();
//
//        return permissions.contains(authority);
//    }

}
